home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 July / macformat-092.iso / Broderbund Demo / DemoData / Mathwork / MATHWORK.Dxr / 00001_Main workshop Scripts.ls next >
Encoding:
Text File  |  1997-08-22  |  10.2 KB  |  440 lines

  1. global gSayWhat, gPictureState, gWhichSprite, gWhichOpening, gFudgeFactor, gAutoInterval, gAutoDelay, gDemoState, gTimeKeeper, gGameList, gViewedList, gRollOverList, gRhythmTime, gRocketTime, gPatternTime, gHiddenTime, gBowlingTime, gSkylightTime, gSticklerTime, gTimerList, gPicNumList, gPicList, gColorDepth, gSkipIntro, gCurrentSound, CloseAudioList, gFinalExit, gVolume, gCorpDemo, gPickerPath, gCorpDemoList, gReturnFrame
  2.  
  3. on TalkPolly
  4.   puppetSound(gSayWhat)
  5. end
  6.  
  7. on CheckTheTimer
  8.   if gCorpDemo = "Picker DemoAll" then
  9.     set gDemoState to 1
  10.   end if
  11.   if (gDemoState = 1) or (the timer > gAutoDelay) then
  12.     startTheDemo()
  13.   end if
  14. end
  15.  
  16. on CheckTheBowlingTimer
  17.   if the timer > gAutoDelay then
  18.     set gDemoState to 1
  19.     go("Leave")
  20.   end if
  21. end
  22.  
  23. on initGlobals
  24.   set the volume of sound 1 to 255
  25.   set the volume of sound 2 to 255
  26.   set gAutoInterval to 5 * 60
  27.   set gAutoDelay to 3 * 60 * 60
  28.   SpriteVisibility(1, 48, 1)
  29.   set gDemoState to 0
  30.   set gGameList to ["HiddenPic", "PuzzlPatt", "SuperStick", "Rhythm", "Rockets", "Bowling", "Skylight"]
  31.   set gViewedList to []
  32.   set gPictureState to 0
  33.   set RhythmCH to 21
  34.   set RocketCH to 23
  35.   set PatternCH to 31
  36.   set HiddenPicCH to 33
  37.   set SuperSticklerCH to 29
  38.   set BowlingCH to 25
  39.   set SkylightCH to 27
  40.   set LeftCloudCH to 35
  41.   set RightCloudCH to 37
  42.   set RhythmTime to 0
  43.   set RocketTime to 0
  44.   set PatternTime to 0
  45.   set HiddenPicTime to 0
  46.   set SuperSticklertime to 0
  47.   set BowlingTime to 0
  48.   set SkyLightTime to 0
  49.   set LeftCloudTime to 0
  50.   set RightCloudTime to 0
  51.   set gRollOverList to [RhythmCH, RocketCH, PatternCH, HiddenPicCH, SuperSticklerCH, BowlingCH, SkylightCH, LeftCloudCH, RightCloudCH]
  52.   set gTimerList to [RhythmTime, RocketTime, PatternTime, HiddenPicTime, SuperSticklertime, BowlingTime, SkyLightTime, LeftCloudTime, RightCloudTime]
  53.   resetDemo()
  54.   set gFinalExit to EMPTY
  55. end
  56.  
  57. on KillTheGlobals
  58.   if voidp(gCorpDemo) then
  59.     clearGlobals()
  60.   end if
  61. end
  62.  
  63. on testrollover
  64.   repeat with x = 1 to 9
  65.     set nextSprite to getAt(gRollOverList, x)
  66.     set whichTime to getAt(gTimerList, x)
  67.     if rollOver(nextSprite + 1) then
  68.       set the visible of sprite nextSprite to 1
  69.       set whichTime to the ticks
  70.       deleteAt(gTimerList, x)
  71.       addAt(gTimerList, x, whichTime)
  72.     end if
  73.   end repeat
  74. end
  75.  
  76. on checkTimes
  77.   repeat with x = 1 to 9
  78.     set origTime to getAt(gTimerList, x)
  79.     set currentSprite to getAt(gRollOverList, x)
  80.     if the ticks > (origTime + 480) then
  81.       set the visible of sprite currentSprite to 0
  82.     end if
  83.   end repeat
  84. end
  85.  
  86. on startMovie
  87.   checkMonitor("start")
  88.   set gVolume to the soundLevel
  89.   if the soundLevel = 0 then
  90.     set the soundLevel to 1
  91.   end if
  92.   initGlobals()
  93.   set the exitLock to 1
  94.   set the volume of sound 1 to 255
  95.   set the volume of sound 2 to 255
  96.   SetUpBowlingInits()
  97. end
  98.  
  99. on keyDown
  100.   checkExit()
  101. end
  102.  
  103. on checkExit
  104.   set QuitMe to 0
  105.   if the keyCode = 53 then
  106.     set QuitMe to 1
  107.   end if
  108.   if the commandDown and ((the key = ".") or (the key = "q")) then
  109.     set QuitMe to 1
  110.   end if
  111.   if QuitMe = 1 then
  112.     if gFinalExit <> "LastRoundUp" then
  113.       setupPuppets(1, 48, 0)
  114.       mouseLock(1)
  115.       set gFinalExit to "LastRoundUp"
  116.       if gCorpDemo = "Picker DemoAll" then
  117.         exitAutoRun()
  118.       else
  119.         go("quit")
  120.       end if
  121.     end if
  122.   end if
  123. end
  124.  
  125. on stopMovie
  126.   resetBowlingInits()
  127.   if voidp(gCorpDemo) then
  128.     checkMonitor("stop")
  129.   end if
  130.   KillTheGlobals()
  131.   sound fadeOut 1, 2 * 60
  132.   sound fadeOut 2, 2 * 60
  133. end
  134.  
  135. on checkMonitor whichState
  136.   if whichState = "start" then
  137.     if the colorDepth <> 8 then
  138.       if the machineType = 256 then
  139.         set Msg to the text of cast "Monitor Alert Message"
  140.         alert(Msg)
  141.         quit()
  142.       else
  143.         set gColorDepth to the colorDepth
  144.         set the colorDepth to 8
  145.       end if
  146.     end if
  147.   else
  148.     if the machineType <> 256 then
  149.       if gColorDepth <> EMPTY then
  150.         set the colorDepth to gColorDepth
  151.       end if
  152.     end if
  153.   end if
  154. end
  155.  
  156. on resetDemo
  157.   set HowManyPics to 7
  158.   set gPicNumList to []
  159.   set gPicList to ["PuzzlePattern", "Rockets", "HiddenPictures", "SuperStickler", "Rhythm", "Bowling", "SkyLight"]
  160.   set totalPick to 0
  161.   set gDemoState to 0
  162.   repeat while totalPick < HowManyPics
  163.     set newNumber to random(HowManyPics)
  164.     if getOne(gPicNumList, newNumber) = 0 then
  165.       add(gPicNumList, newNumber)
  166.       set totalPick to totalPick + 1
  167.     end if
  168.   end repeat
  169. end
  170.  
  171. on exitAutoRun
  172.   puppetSprite(48, 0)
  173.   setupPuppets(1, 48, 0)
  174.   mouseLock(1)
  175.   if gCorpDemo = "Picker DemoAll" then
  176.     set gCorpDemo to "Picker DemoNone"
  177.     go("logo", gPickerPath)
  178.     dontPassEvent()
  179.   else
  180.     sound close 1
  181.     sound close 2
  182.     initGlobals()
  183.     puppetSound(0)
  184.     dontPassEvent()
  185.     go("Begin")
  186.   end if
  187. end
  188.  
  189. on startTheDemo
  190.   if gCorpDemo = "Picker DemoNone" then
  191.     set gCorpDemo to "Picker DemoAll"
  192.     go("returnFade", gPickerPath)
  193.     exit
  194.   end if
  195.   set gDemoState to 1
  196.   mouseLock(0)
  197.   set the mouseDownScript to "exitAutoRun"
  198.   setupPuppets(1, 48, 0)
  199.   if the timer > gAutoInterval then
  200.     if gPicNumList = [] then
  201.       go("WhistleUp")
  202.       exit
  203.     end if
  204.     set nextRanNum to getAt(gPicNumList, 1)
  205.     set nextPicToSee to getAt(gPicList, nextRanNum)
  206.     deleteAt(gPicNumList, 1)
  207.     go(nextPicToSee)
  208.   end if
  209. end
  210.  
  211. on setupPuppets start, end, switch
  212.   repeat with x = start to end
  213.     puppetSprite(x, switch)
  214.   end repeat
  215. end
  216.  
  217. on SpriteVisibility start, end, switch
  218.   repeat with x = start to end
  219.     set the visible of sprite x to switch
  220.   end repeat
  221. end
  222.  
  223. on ButtonHiLite
  224.   set whichNumber to the castNum of sprite the clickOn
  225.   if rollOver(the clickOn) = 1 then
  226.     set the hilite of cast whichNumber to 1
  227.   else
  228.     set the hilite of cast whichNumber to 0
  229.   end if
  230. end
  231.  
  232. on SpriteHiLite oldCast, newCast
  233.   if rollOver(the clickOn) = 1 then
  234.     set newCastNum to the number of member newCast
  235.     set the castNum of sprite the clickOn to newCastNum
  236.     updateStage()
  237.   else
  238.     set oldCastNum to the number of member oldCast
  239.     set the castNum of sprite the clickOn to oldCastNum
  240.     updateStage()
  241.   end if
  242. end
  243.  
  244. on BlinkGus
  245.   if random(20) = 5 then
  246.     set newCast to the number of member "GusBlink"
  247.     set oldCast to the castNum of sprite 16
  248.     set the castNum of sprite 16 to newCast
  249.     updateStage()
  250.     miniDelay(0.20000000000000001)
  251.     set the castNum of sprite 16 to oldCast
  252.     updateStage()
  253.   end if
  254. end
  255.  
  256. on shutDownBowling
  257.   set counter to 1
  258.   repeat while counter < 49
  259.     puppetSprite(counter, 0)
  260.     set counter to counter + 1
  261.   end repeat
  262.   if gDemoState <> 1 then
  263.     mouseLock(1)
  264.   end if
  265.   puppetSound(0)
  266.   set the volume of sound 1 to 255
  267.   set the volume of sound 2 to 255
  268. end
  269.  
  270. on miniDelay Howlong
  271.   set startTime to the ticks
  272.   set DoneTime to the ticks + (Howlong * 60)
  273.   set done to 0
  274.   repeat while done = 0
  275.     if the ticks > DoneTime then
  276.       set done to 1
  277.     end if
  278.   end repeat
  279. end
  280.  
  281. on SkipAhead goWhere
  282.   if gCorpDemo = "Picker DemoAll" then
  283.     set gCorpDemo to "Picker DemoNone"
  284.     go("logo", gPickerPath)
  285.     dontPassEvent()
  286.   else
  287.     dontPassEvent()
  288.     sound stop 1
  289.     updateStage()
  290.     mouseLock(1)
  291.     go(goWhere)
  292.   end if
  293. end
  294.  
  295. on doButtonHilite goWhere
  296.   set myNormalButton to the castNum of sprite the clickOn
  297.   set myHiliteButton to myNormalButton + 1
  298.   set myButtonSprite to the clickOn
  299.   set myMouseDownSound to "mapbutdn"
  300.   set myMouseUpSound to "mapbutup"
  301.   set the castNum of sprite myButtonSprite to myHiliteButton
  302.   puppetSound(myMouseDownSound)
  303.   updateStage()
  304.   repeat while soundBusy(1) = 1
  305.     nothing()
  306.   end repeat
  307.   puppetSound(0)
  308.   if goWhere <> "WhistleUp" then
  309.     repeat while the stillDown
  310.       if rollOver(myButtonSprite) = 1 then
  311.         set the castNum of sprite myButtonSprite to myHiliteButton
  312.       else
  313.         set the castNum of sprite myButtonSprite to myNormalButton
  314.       end if
  315.       updateStage()
  316.     end repeat
  317.   end if
  318.   set the castNum of sprite myButtonSprite to myNormalButton
  319.   puppetSound(0)
  320.   updateStage()
  321.   if goWhere = "WhistleUp" then
  322.     mouseLock(1)
  323.     go(goWhere)
  324.     exit
  325.   end if
  326.   if rollOver(myButtonSprite) = 1 then
  327.     updateStage()
  328.     puppetSound(0)
  329.     if goWhere = "leave2" then
  330.       shutDownBowling()
  331.     end if
  332.     mouseLock(1)
  333.     go(goWhere)
  334.     exit
  335.   end if
  336.   repeat while soundBusy(1)
  337.     nothing()
  338.   end repeat
  339.   puppetSound(0)
  340.   updateStage()
  341. end
  342.  
  343. on StopGusMusic
  344.   sound fadeOut 2, 2 * 60
  345.   puppetSprite(16, 0)
  346.   mouseLock(0)
  347.   go(marker(1))
  348. end
  349.  
  350. on mouseLock LockState
  351.   global gDemoState
  352.   if gDemoState <> 1 then
  353.     if LockState = 0 then
  354.       set the mouseDownScript to EMPTY
  355.       set the mouseUpScript to EMPTY
  356.     else
  357.       set the mouseDownScript to "DontPassEvent"
  358.       set the mouseUpScript to "DontPassEvent"
  359.     end if
  360.   end if
  361. end
  362.  
  363. on SkipTheOpening goWhere, killsound
  364.   if gCorpDemo = "Picker DemoAll" then
  365.     set gCorpDemo to "Picker DemoNone"
  366.     go("logo", gPickerPath)
  367.     dontPassEvent()
  368.   else
  369.     mouseLock(1)
  370.     startTimer()
  371.     if killsound = 1 then
  372.       sound fadeOut 2, 30
  373.     end if
  374.     go(goWhere)
  375.   end if
  376. end
  377.  
  378. on SkipIntro
  379.   sound stop 1
  380.   updateStage()
  381.   set gSkipIntro to 1
  382.   SkipAhead("TurnBack")
  383. end
  384.  
  385. on MacAudio howmanyFrames
  386.   if the machineType <> 256 then
  387.     go(the frame + howmanyFrames)
  388.   end if
  389. end
  390.  
  391. on initCloseAudio
  392.   set CloseAudioList to ["MWS_110.aif", "MWS_111.AIF", "MWS_112.AIF"]
  393.   set gCurrentSound to getAt(CloseAudioList, 1)
  394.   puppetSound(gCurrentSound)
  395. end
  396.  
  397. on closeAudioTest
  398.   if soundBusy(1) = 0 then
  399.     set whichSound to getOne(CloseAudioList, gCurrentSound)
  400.     if whichSound < count(CloseAudioList) then
  401.       set gCurrentSound to getAt(CloseAudioList, whichSound + 1)
  402.       puppetSound(gCurrentSound)
  403.       go(the frame)
  404.     else
  405.       exit
  406.     end if
  407.   else
  408.     go(the frame)
  409.   end if
  410. end
  411.  
  412. on doCloseButtonHilite actionHandler
  413.   if gDemoState = 1 then
  414.     exitAutoRun()
  415.   else
  416.     set myNormalButton to the castNum of sprite the clickOn
  417.     set myHiliteButton to myNormalButton + 1
  418.     set myButtonSprite to the clickOn
  419.     set the castNum of sprite myButtonSprite to myHiliteButton
  420.     repeat while the stillDown
  421.       if rollOver(myButtonSprite) = 1 then
  422.         set the castNum of sprite myButtonSprite to myHiliteButton
  423.       else
  424.         set the castNum of sprite myButtonSprite to myNormalButton
  425.       end if
  426.       updateStage()
  427.     end repeat
  428.     set the castNum of sprite myButtonSprite to myNormalButton
  429.     updateStage()
  430.   end if
  431. end
  432.  
  433. on rightMouseDown
  434.   dontPassEvent()
  435. end
  436.  
  437. on rightMouseUp
  438.   dontPassEvent()
  439. end
  440.